package com.learn.my;

import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

public class Test0005 {


    public static void main(String[] args){

        //可定时操作任务
        ScheduledExecutorService newScheduledThreadPool = Executors.newScheduledThreadPool(3);

        for (int i = 0; i < 20; i++) {
            final  int temp=i;
             newScheduledThreadPool.schedule(new Runnable() {
                public void run() {
                    System.out.println(Thread.currentThread().getName()+","+temp);
                }
            },3, TimeUnit.SECONDS);
        }
    }
}
